package com.example.zyf.sortlistviewandsidebar;


import java.io.Serializable;

public class CityModel implements Serializable {
	@Override
	public String toString() {
		return "CityModel [cityName=" + cityName + ", cityInitial="
				+ cityInitial + "]";
	}
	
	private String cityCode;
	private String provinceCode;
	private String cityName;
	private String cityInitial;
	public String getCityCode() {
		return cityCode;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((cityCode == null) ? 0 : cityCode.hashCode());
		result = prime * result
				+ ((cityInitial == null) ? 0 : cityInitial.hashCode());
		result = prime * result
				+ ((cityName == null) ? 0 : cityName.hashCode());
		result = prime * result
				+ ((provinceCode == null) ? 0 : provinceCode.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		CityModel other = (CityModel) obj;
		if (cityCode == null) {
			if (other.cityCode != null)
				return false;
		} else if (!cityCode.equals(other.cityCode))
			return false;
		if (cityInitial == null) {
			if (other.cityInitial != null)
				return false;
		} else if (!cityInitial.equals(other.cityInitial))
			return false;
		if (cityName == null) {
			if (other.cityName != null)
				return false;
		} else if (!cityName.equals(other.cityName))
			return false;
		if (provinceCode == null) {
			if (other.provinceCode != null)
				return false;
		} else if (!provinceCode.equals(other.provinceCode))
			return false;
		return true;
	}
	public void setCityCode(String cityCode) {
		this.cityCode = cityCode;
	}
	public String getProvinceCode() {
		return provinceCode;
	}
	public void setProvinceCode(String provinceCode) {
		this.provinceCode = provinceCode;
	}
	public String getCityName() {
		return cityName;
	}
	public void setCityName(String cityName) {
		this.cityName = cityName;
	}
	public String getCityInitial() {
		if(this.cityInitial.equals(PinyinComparator.SELECTED_CITY)){
			return cityInitial;
		}
		else{
			return cityInitial.substring(0, 1);
		}
	}
	public void setCityInitial(String cityInitial) {
		this.cityInitial = cityInitial;
	}
	
    public static CityModel getDefaultCity(){
		CityModel cm=new CityModel();
		cm.setCityInitial(PinyinComparator.SELECTED_CITY);
		cm.setCityCode("2900");
		cm.setCityName("上海市");
		cm.setProvinceCode("2900");
		return cm;
	}
}
